<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>表格单选</title>
    <script src="../lib/easytable.js"></script>
    <link type="text/css" rel="stylesheet" href="../lib/easytable.css" />
    <script>
        let table;
        window.onload = function () {
            let option = {
                cols: [{ type: 'radio' }, { title: '名字', field: 'name' },
                { title: '学号', field: 'num' }, { title: '成绩', field: 'mark' }, { title: '性别', field: 'sex' }],
                data: [{ name: 'yh', num: 123, mark: 99, sex: '男' }, { name: 'yh', num: 123, mark: 99, sex: '男' }, { name: 'yh', num: 123, mark: 99, sex: '男' }]
            }
            table = new easytable("table", option);
        }
        function selectData() {
            alert(JSON.stringify(table.getSelectedData()));
        }
    </script>
</head>

<body>
    <table id='table'></table>
    <button onclick="selectData()">获取选中行数据</button>
</body>

</html>